<template>
  <div>
    <!-- 表单 -->
    <el-form :inline="true">
      <el-form-item label="赠送对象">
        <el-input placeholder="请输入赠送对象关键字"></el-input>
      </el-form-item>
      <el-form-item label="优惠券名称">
        <el-input
          v-model="name"
          placeholder="请输入优惠券名称关键字"
        ></el-input>
      </el-form-item>
      <el-button @click="search">搜索</el-button>
      <el-button @click="reset">重置</el-button>
    </el-form>
    <!-- 表格 -->
    <el-table :data="res" border style="width: 100%,text-align:center ">
      <el-table-column prop="coupon" label="优惠券名称" width="180">
      </el-table-column>
      <el-table-column prop="total" label="赠送对象" width="180">
      </el-table-column>
      <el-table-column prop="" label="赠送日期"
        ><template>
          {{ time }}
        </template>
      </el-table-column>
      <el-table-column prop="used" label="使用/赠送">
      </el-table-column>
      <el-table-column prop="address" label="操作">
        <el-link @click="gotodetail">查看详情</el-link>-<el-link
          >已经撤销</el-link
        ></el-table-column
      >
    </el-table>
    <el-pagination
      background
      layout="total, sizes, prev, pager, next, jumper"
      :total="handSel.length"
      :page-sizes="[1]"
      :page-size="pagesize"
      :current-page="pagenum"
      @size-change="sizechange"
      @current-change="pagechange"
    >
    </el-pagination>
  </div>
</template>
<script>
import { gethandSel } from "../../../api/api4";
export default {
  data() {
    return {
      list: [],
      time: new Date().toLocaleString(),
      handSel: [],
      pagesize: 1,
      pagenum: 1,
    };
  },
  created() {
    gethandSel().then((res) => {
      if (res) {
        this.handSel = res.data.list;
        this.list = res.data.list;
      }
    });
  },
  methods: {
    // CouponPresent
    gotodetail() {
      this.$router.push({ name: "CouponPresentdetail" });
    },
    sizechange(val) {
      console.log(val);
      this.pagesize = val;
    },

    pagechange(val) {
      console.log(val);
      this.pagenum = val;
    },
  },
  computed: {
    res() {
      return this.handSel.slice(
        this.pagesize * (this.pagenum - 1),
        this.pagesize * this.pagenum
      );
    },
  },
};
</script>
